package com.examination.client.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.examination.client.domian.dto.QueryOrderDTO;
import com.examination.client.domian.dto.QueryOrderRecordDTO;
import com.examination.client.domian.vo.OrderRecordVO;
import com.examination.client.domian.vo.QueryOrderRecordVO;
import com.examination.client.service.OrderService;
import com.examination.client.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("/order")
@Api(tags = "订单相关")
@CrossOrigin(origins = "*")
public class OrderController {
    @Resource
    OrderService orderService;

    /**
     * 订单列表
     */
    @ApiOperation("订单列表")
    @ResponseBody
    @PostMapping(value = "/list")
    public Result<Page<OrderRecordVO>> list(@RequestBody @Validated QueryOrderDTO queryOrderDTO) {
        return Result.success(orderService.list(queryOrderDTO));
    }

    /**
     * 后端订单列表
     */
    @ApiOperation("后端订单记录")
    @ResponseBody
    @PostMapping(value = "/record")
    public Result<Page<QueryOrderRecordVO>> record(@RequestBody @Validated QueryOrderRecordDTO queryOrderRecordDTO) {
        return Result.success(orderService.record(queryOrderRecordDTO));
    }
}
